package com.jiangyao.controller;

import com.jiangyao.common.ApiResult;
import com.jiangyao.model.dto.backend.UserExperienceDTO;
import com.jiangyao.model.dto.backend.UserExperienceDetailDTO;
import com.jiangyao.model.dto.backend.UserExperienceListPageDTO;
import com.jiangyao.model.vo.backend.UserExperienceListVO;
import com.jiangyao.service.UserExperienceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 个人档案 controller
 *
 * @author: yangyongchuan
 * @create: 2020年09月05日 13:26
 */
@RestController
@RequestMapping("/userExperience")
@Api(tags = "个人档案管理")
public class UserExperienceController extends BaseController {

	@Autowired
	private UserExperienceService userExperienceService;

	/**
	 * 获取个人档案列表
	 *
	 * @param listPageDTO 列表DTO
	 * @return 结果
	 */
	@ApiOperation(value = "获取个人档案列表")
	@PostMapping("/list")
	public ApiResult<UserExperienceListVO> getListPage(@Validated({UserExperienceListPageDTO.ListPage.class}) @RequestBody UserExperienceListPageDTO listPageDTO) {
		return ApiResult.success(userExperienceService.getListPage(listPageDTO));
	}


	/**
	 * 添加个人档案
	 *
	 * @param addDTO 添加个人档案DTO
	 * @return 结果
	 */
	@ApiOperation(value = "添加个人档案")
	@PostMapping("/add")
	public ApiResult<String> add(@Validated({UserExperienceDTO.Add.class}) @RequestBody UserExperienceDTO addDTO) {
		userExperienceService.add(addDTO);
		return new ApiResult<>();
	}

	/**
	 * 编辑个人档案
	 *
	 * @param editDTO 添加个人档案DTO
	 * @return 结果
	 */
	@ApiOperation(value = "编辑个人档案")
	@PostMapping("/edit")
	public ApiResult<String> edit(@Validated({UserExperienceDTO.Edit.class}) @RequestBody UserExperienceDTO editDTO) {
		userExperienceService.edit(editDTO);
		return new ApiResult<>();
	}

	/**
	 * 编辑审核状态
	 *
	 * @param auditDTO 审核DTO
	 * @return 结果
	 */
	@ApiOperation(value = "编辑审核状态", notes = "必填字段：idList,status")
	@PostMapping("/editStatus")
	public ApiResult<String> editStatus(@Validated({UserExperienceDTO.Audit.class}) @RequestBody UserExperienceDTO auditDTO) {
		userExperienceService.editStatus(auditDTO);
		return new ApiResult<>();
	}

	/**
	 * 获取个人档案详情
	 *
	 * @param detailDTO 详情DTO
	 * @return 结果
	 */
	@ApiOperation(value = "获取个人档案详情")
	@PostMapping("/detail")
	public ApiResult<UserExperienceListVO> getDetail(@Validated({UserExperienceDetailDTO.Detail.class}) @RequestBody UserExperienceDetailDTO detailDTO) {
		return ApiResult.success(userExperienceService.getDetail(detailDTO));
	}
}
